package com.bigflexlib.x.com.adobe.net.URI
{
	import com.adobe.net.URI;
	import com.bigflexlib.core.markers.IValueSingleton;
	
	/**
	 * 
	 * TODO: garbage collection
	 * 
	 * @author aldo.bucchi@univrz.com
	 * 
	 */	
	public class URIValueSingletonFactory implements IValueSingleton
	{
		
		
		private static var cache:Object = { };



		public static function forURI( uri:URI ):URI
		{
			var uriString:String = uri.toString( );
			
			if ( cache[uriString] )
				return cache[ uriString ];
			
			cache[uriString] = uri;
			
			return uri;	
		}
		


		public static function forString( uriString:String ):URI
		{
			if ( cache[uriString] )
				return cache[ uriString ];
				
			var uri:URI = new URI( uriString );
			
			cache[ uriString ] = uri;
			
			return uri;			
		}

	}
}